<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>出校申请</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="../js/vue.js"></script>
  <script src="../js/axios-0.18.0.js"></script>
  <script src="../element-ui/lib/index.js"></script>
  <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="div">
  <el-row>
    <el-col :span="7">
      <div class="grid-content bg-purple">
        <span style="color: #FFFFFF">王凤我爱你</span>
      </div>
    </el-col>
    <el-col :span="9">
      <div class="grid-content bg-purple-dark">
        <el-container>
          <el-header style="text-align: center; font-size: 12px">
            <div style="margin-left: 50px;font-size: 20px">校门申请</div>
          </el-header>
          <el-form :label-position="'left'" label-width="200px" :model="dateFrom">
            <el-form-item label="姓名">
              <el-input v-model="dateFrom.name" style="width: 300px"></el-input>
            </el-form-item>
            <el-form-item label="身份证号码">
              <el-input v-model="dateFrom.identification" style="width: 300px"></el-input>
            </el-form-item>
            <el-form-item label="类型">
<!--              <el-switch v-model="dateFrom.type"></el-switch>-->
              <el-radio v-model="dateFrom.type" label="true">出校</el-radio>
              <el-radio v-model="dateFrom.type" label="false">返校</el-radio>
            </el-form-item>
            <el-form-item align="center">
              <el-button type="primary" @click="addCheckin()" style="text-align: center;">申请</el-button>
            </el-form-item>
          </el-form>
        </el-container>
      </div>
    </el-col>
    <el-col :span="7">
      <div class="grid-content bg-purple">
        <span style="color: #FFFFFF">王凤我爱你</span>
      </div>
    </el-col>
  </el-row>
</div>


<script>
  new Vue({
    el: "#div",
    data: {
      dateFrom: {},
      now_date:{},
      user:{},
      userInfo:{},
    },
    methods: {
      addCheckin() {
        let param = "action=apply&name=" + this.dateFrom.name +
                "&identification=" + this.dateFrom.identification +
                "&type=" + this.dateFrom.type +
                "&number=" + this.userInfo.userNumber +
                "&date=" + this.now_date;
        console.log(param);
        axios.post("/EpidemicControlSystem_war_exploded/OutApplyServlet", param)
                .then(res => {
                  if (res.data == true) {
                    alert('申请成功');
                  } else {
                    alert('已存在申请，请耐心等待。在申请记录中查询')
                  }
                })
      },
      getNowTime(){
        var d = new Date(), str = '';
        str += d.getFullYear() + '-'; //获取当前年份
        str += d.getMonth() + 1 + '-'; //获取当前月份（0——11）
        str += d.getDate() + '';
        this.now_date = str;
      },
      getUser(){
        axios.post("/EpidemicControlSystem_war_exploded/UserServlet", "action=user")
                .then(res => {
                  this.user = res.data.loginUser;
                  this.userInfo = res.data.loginUserInfo;
                  this.dateFrom = this.userInfo;
                  console.log(this.userInfo.userNumber);
                });
      }
    },
    created() {
      this.getNowTime();
      this.getUser();
    }

  });
</script>
</body>
</html>